package com.vivo.tasks;

import com.vivo.common.quartz.QuartzUtil;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

@Component
public class Car {

    private Logger logger = Logger.getLogger(Car.class);
    private DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    public void starting() {
        logger.info(df.format(new Date()) + "---------->车辆启动");
        System.out.println(df.format(new Date()) + "---------->车辆启动");

        String mainJob = QuartzUtil.getScheduleJobName("car_starting");
        QuartzUtil.executeChildJobs(mainJob);
    }

    public void running() {
        logger.info(df.format(new Date()) + "---------->车辆开动");

        String mainJob = QuartzUtil.getScheduleJobName("car_running");
        QuartzUtil.executeChildJobs(mainJob);
    }

    public void stop() {
        logger.info(df.format(new Date()) + "---------->车辆停止");

        String mainJob = QuartzUtil.getScheduleJobName("car_stop");
        QuartzUtil.executeChildJobs(mainJob);
    }
}
